<style>
  #sendBack-add {
    padding: 20px 25px 25px 0;
  }

  #sendBack-add .layui-treeSelect .ztree li a, .ztree li span {
    margin: 0 0 2px 3px !important;
  }
</style>
<div class="layui-fluid" id="sendBack-add" title="退书信息登记">
  <form class="layui-form" action="" lay-filter="sendBack-add-form">
    <div class="layui-form-item">
      <label class="layui-form-label febs-form-item-require">图书名称：</label>
      <div class="layui-input-block">
        <input type="text" name="bookname" id="bookname" maxlength="20" lay-verify="required"
               autocomplete="off" class="layui-input">
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label febs-form-item-require">图书类型：</label>
      <div class="layui-input-block">
        <input type="text" name="booktype" id="booktype" autocomplete="off" class="layui-input"
               lay-verify="required" readonly>
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label febs-form-item-require">出版社：</label>
      <div class="layui-input-block">
        <input type="text" name="pubid" id="pubid" minlength="1" maxlength="10" lay-verify="range"
               autocomplete="off" class="layui-input" readonly>
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label febs-form-item-require">价格：</label>
      <div class="layui-input-block">
        <input type="text" name="bookmoney" id="bookmoney" autocomplete="off" class="layui-input"
               lay-verify="required" readonly>
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label febs-form-item-require">退书数量：</label>
      <div class="layui-input-block">
        <input type="text" name="number" autocomplete="off" class="layui-input"
               lay-verify="required|number">
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label febs-form-item-require">退书客户：</label>
      <div class="layui-input-block">
        <input type="text" name="principal" autocomplete="off" class="layui-input"
               lay-verify="required">
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label febs-form-item-require">退书说明：</label>
      <div class="layui-input-block">
        <input type="text" name="message" autocomplete="off" class="layui-input"
               lay-verify="required">
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label febs-form-item-require">下单时间：</label>
      <div class="layui-input-block">
        <input type="text" name="indentdate" id="indentdate" autocomplete="off" class="layui-input"
               lay-verify="required" readonly>
      </div>
    </div>
    <div class="layui-form-item febs-hide">
      <button class="layui-btn" lay-submit="" lay-filter="sendBack-add-form-submit" id="submit"></button>
      <button type="reset" class="layui-btn" id="reset"></button>
    </div>
  </form>
</div>

<script  data-th-inline="javascript">
  layui.use(['febs', 'form', 'validate', 'laydate'], function () {
    var $ = layui.$,
        febs = layui.febs,
        layer = layui.layer,
        form = layui.form,
        laydate = layui.laydate,
        $view = $('#sendBack-add'),
        validate = layui.validate;

    form.verify(validate);
    form.render();


    laydate.render({
      elem: '#indentdate',
      trigger: 'click',
      type: 'date'
    });

    $(function () {
      var bookname = '';
      $('#bookname').on('input', function (msg) {
        bookname = msg.delegateTarget.value;
        $.ajax({
          url: ctx + 'bookIndent',
          data: {bookname: bookname},
          dataType: 'JSON',
          cache: false,
          contentType: "application/json;charset=utf-8",
          success: function (res) {
            var data = res.data;
            for (let dataKey in data) {
              if (data[dataKey].createtime == null) {
                var str = data[dataKey];
              }
            }
            $('#booktype').val(str.type);
            $('#pubid').val(str.pubid);
            $('#bookmoney').val(str.bookmoney);
          }
        });
      });
    });

    form.on('submit(sendBack-add-form-submit)', function (data) {
      febs.post(ctx + 'sendBack', data.field, function () {
        layer.closeAll();
        febs.alert.success('报损信息添加成功');
        $('#febs-sendBack').find('#query').click();
      });
      return false;
    });
  });
</script>